package resources;

import java.awt.Color;

import javax.swing.JPanel;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;

import cii_lib.CCII_ACCESS_INTERF;

/**
 * @author pdrabik
 * 
 */
public class DataCardChars implements DataDisplayable {

	private XYSeries series = new XYSeries("Value");
	private DataGenerator dg;
	private CCII_ACCESS_INTERF inter;
	
	public DataCardChars(CCII_ACCESS_INTERF intr) {
		inter = intr;
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see resources.DataDisplayable#getDefaultChartPanel()
	 */
	public JPanel getDefaultChartPanel() {
		// TODO Auto-generated method stub
		
		XYDataset xyDataset = new XYSeriesCollection(series);
		JFreeChart chart = ChartFactory.createScatterPlot
//		JFreeChart chart = ChartFactory.createXYLineChart
				(""+inter.Name(), // Title
				"Samples", // X-Axis label
				"Values", // Y-Axis label
				xyDataset, // Dataset
				PlotOrientation.VERTICAL, 
				false, // Show legend
				true, false);
		chart.getXYPlot().setBackgroundPaint(Color.black);
		chart.getXYPlot().getRenderer().setSeriesPaint(0, Color.GREEN);
		ChartPanel cpanel = new ChartPanel(chart);
		// cpanel.setVerticalAxisTrace(false);
		cpanel.setVerticalAxisTrace(true);
		cpanel.setHorizontalAxisTrace(true);
		cpanel.setRangeZoomable(true);
		cpanel.setFillZoomRectangle(true);
		cpanel.setMouseWheelEnabled(true);
//		cpanel.getPopupMenu();
		//TODO no nie wiem czy tak zostawic, warto zrobic w sposob 'delegacji'
		dg = new DataGenerator(170,(XYSeriesCollection)xyDataset,inter); 
//		dg.start("tratata");
//		dg.stop();
		return cpanel;
	}

	/* (non-Javadoc)
	 * @see resources.DataDisplayable#getDataStore()
	 */
	public Object getDataStore() {
		// TODO Auto-generated method stub
		return series;	
	}

	/* (non-Javadoc)
	 * @see resources.DataDisplayable#setDataStore()
	 */
	public void setDataStore() {
		// TODO Auto-generated method stub
		
	}

	/* (non-Javadoc)
	 * @see resources.DataDisplayable#updateDataStore()
	 */
	public void updateDataStore() {
		// TODO Auto-generated method stub
		
	}
	
	public DataGenerator getDataGenerator() {
		return dg;
	}
	public void setDataGenerator(DataGenerator datagen) {
		dg = datagen;
	}

}
